﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using VSSAHT;
using VSS_AHT.Properties;

namespace VSS_AHT
{
    public partial class FormConfigPrinter : BaseForm
    {
        #region Declare Availables
        //private readonly SettingApp _settings = new SettingApp();
        #endregion

        #region Sigletons Members

        private static volatile FormConfigPrinter instance;
        private static object syncRoot = new Object();

        public static FormConfigPrinter Instance
        {
            get
            {
                lock (syncRoot)
                {
                    if (instance == null)
                    {
                        instance = new FormConfigPrinter();
                    }
                }
                return instance;
            }

        }
        #endregion

        #region Ctors

        public FormConfigPrinter()
        {
            InitializeComponent();
            //Initialize();
            this.Disposed += new EventHandler(delegate { instance = null; });
        }

        public void Initialize()
        {
            //txtPrinterReceipt.Text = _settings.ReceiptPrintName;
            //txtPrinterReport.Text = _settings.ReportPrintName;
            //chkPreviewReceipt.Checked = _settings.IsPreviewReceiptPrint;
            //chkPreviewReport.Checked = _settings.IsPreviewReportPrint;

            //txtMarginLeft.Text = _settings.MarginLeft.ToString();
            //txtMarginRight.Text = _settings.MarginRight.ToString();
            //txtMarginTop.Text = _settings.MarginTop.ToString();
            //txtMarginBottom.Text = _settings.MarginBottom.ToString();

            //this.btnSave.Click += new EventHandler(delegate { ClickButtonSave(); });
            //this.btnCancel.Click += new EventHandler(delegate
            //{
            //    this.Close();
            //});

            ////printer
            //#region Printer
            //this.btnPrinterReceipt.Click += new EventHandler(delegate
            //{
            //    PrintDialog printDialog1 = new PrintDialog();
            //    printDialog1.ShowDialog();
            //    txtPrinterReceipt.Text = printDialog1.PrinterSettings.PrinterName.ToString();
            //});

            //this.btnPrinterReport.Click += new EventHandler(delegate
            //{
            //    PrintDialog printDialog1 = new PrintDialog();
            //    printDialog1.ShowDialog();
            //    txtPrinterReport.Text = printDialog1.PrinterSettings.PrinterName.ToString();
            //});
            //#endregion
        }
        #endregion

        #region Methods
        //private void ClickButtonSave()
        //{
        //    try
        //    {
                
        //        _settings.ReceiptPrintName = txtPrinterReceipt.Text;
        //        _settings.ReportPrintName = txtPrinterReport.Text;
        //        _settings.IsPreviewReceiptPrint = chkPreviewReceipt.Checked;
        //        _settings.IsPreviewReportPrint = chkPreviewReport.Checked;

        //        _settings.MarginLeft =Convert.ToInt32(txtMarginLeft.Text.Trim());
        //        _settings.MarginRight = Convert.ToInt32(txtMarginRight.Text.Trim());
        //        _settings.MarginTop =  Convert.ToInt32(txtMarginTop.Text);
        //        _settings.MarginBottom =  Convert.ToInt32(txtMarginBottom.Text);

               
        //        Settings.Default.Save();

        //        Common.InitPort();

        //        Common.ShowSuccessful("Lưu cấu hình thành công!");
        //    }
        //    catch (Exception ex)
        //    {
        //        Common.ShowAlert("Lưu cấu hình thất bại => ERROR! " + ex.Message);
        //    }
        //}
        //#endregion

      
        //#region Events
        //protected override void OnClosed(EventArgs e)
        //{
        //    instance = null;
        //    Settings.Default.Reload();
        //    base.OnClosed(e);
        //}
        #endregion



    }
}